package com.moonshineproject.plugin.settings.vo
{
    import com.moonshineproject.plugin.settings.ISettingsProvider;
    import com.moonshineproject.plugin.settings.renderers.BooleanRenderer;

    import mx.core.IVisualElement;

    public class BooleanSetting extends AbstractSetting
    {

        public function BooleanSetting(provider:Object, name:String, label:String)
        {
            super();
            this.provider = provider;
            this.name = name;
            this.label = label;
            defaultValue = stringValue;
        }


        override protected function setPendingSetting(v:*):void
        {
            super.setPendingSetting(v is String ? v == "true" ? true : false : v);
        }

        [Bindable]
        public function get value():Boolean
        {
            var val:String = getSetting();
            return val == "true" ? true : false;
        }

        public function set value(v:Boolean):void
        {
            setPendingSetting(v);
        }

        override public function get renderer():IVisualElement
        {
            var rdr:BooleanRenderer = new BooleanRenderer();
            rdr.setting = this;

            return rdr;
        }

    }
}